
package id.isran.kamusindonesiamuna.adapter;

import id.isran.kamusindonesiamuna.entity.E_Fragment;
import java.util.List;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * Class Adapter untuk fragment
 */
public class FragmentAdapter extends FragmentPagerAdapter {

    private List<E_Fragment> listFragment;
    private Context context;

    /**
     * Constructor class FragmentAdapter
     * 
     * @param context Context activity
     * @param fm FragmentManager
     * @param listFragment ListFragment
     */
    public FragmentAdapter(Context context, FragmentManager fm, List<E_Fragment> listFragment) {
        super(fm);
        this.listFragment = listFragment;
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return Fragment.instantiate(context, listFragment.get(position).getFragment());
    }

    @Override
    public int getCount() {
        return listFragment.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return listFragment.get(position).getTitle();
    }

}
